#include <thread>
#include <mutex>
#include "VedioRecord.h"
#include "vpu.h"
#include <time.h>

static int recordState = 0;//0表示不录制  1表示录制
std::mutex dataMtx;


void LockVedioRecord()
{
    dataMtx.lock();
}

void UnLockVedioRecord()
{
    dataMtx.unlock();
}


void StartVedioRecord()
{
    if(recordState==1)
    {
        return;
    }
    time_t timer;//time_t就是long int 类型
    struct tm *tblock;
    timer = time(NULL);
    tblock = localtime(&timer);
//    printf("Local time is: %s\n", asctime(tblock));
    recordState = 1;
//    std::thread(EncodeFun,asctime(tblock)).detach();
    std::thread(EncodeFun,asctime(tblock)).detach();
}

void StopVedioRecord()
{
    recordState = 0;
}

int GetRecordState()
{
    return recordState;
}
